<!DOCTYPE html>
<html lang="zh-cmn-Hans">
<head>
    <meta charset="UTF-8">
    <title>添加文档</title>
    <link rel="stylesheet" type="text/css" href="../css/index.css?v=_VERSION_" />
    <script src="../js/jquery.js" type="text/javascript" charset="utf-8"></script>
    <script language="javascript" type="text/javascript" src="../js/My97DatePicker/WdatePicker.js"></script>
</head>
<body>


<div class="add-d-main">
    <div class="add-d-box1">
        <div class="titlepsss" style="padding-bottom: 10px;">
            <span class="lintp"></span>
            <a href="" title="" class="act" style="padding-bottom: 13px;width: 65px;margin-left: -14px;text-align: right;line-height: 40px;">添加文档<em></em></a>

        </div>
    </div>

    <div class="add-d-box2">
        <ul>
            <li class="add-d-li1">
                <span>文章标题：</span>
                <input name="title" type="text" id="title" value="" style="width:388px">
            </li>
            <li class="add-d-li2" style="height: initial">
                <span>缩略图：</span>
                <input type="file"onchange="selectImage(this);" name="" id="" style="width:155px;cursor:pointer;" class="add-d-button">
                <input class="add-d-input1" type="button"onclick="uploadImage();"value="上传"/>


            </li>
            <li class="add-d-li3">
                <span>内容摘要：</span>
                <textarea name="description" rows="5" id="description" style="width:50%;height:50px;margin-top: 15px;"></textarea>
            </li>
            <li class="gettime add-d-li4" style="display:block;">
                <span>发布时间：</span>
                <input type="text" name="" id="" value="" placeholder="2017-01-01" class="Wdate" onclick="WdatePicker()">
                <span>截止时间：</span>
                <input type="text" name="" id="" value="" placeholder="2017-01-01" class="Wdate" onclick="WdatePicker()">
            </li>
        </ul>
    </div>

    <div class="add-d-box3">
        <div class="editor"><img src="../images/bianjiqi.jpg" style="width: 100%"></div>
        <div class="edit-content">
            <textarea name="MSG" cols=40 rows=4>
                中国外汇交易中心受权公布人民币汇率中间...中国外汇交易中心受权公布人民币汇率中间...中国外汇交易中心受权公布人民币汇率中间
中国外汇交易中心受权公布人民币汇率中间...中国外汇交易中心受权公布人民币汇率中间...
            </textarea>
        </div>
    </div>

    <div class="add-d-box4">
        <input type="button" onclick="history.back();" id="" value="保存" class="newsub">
        <input type="button" onclick="javascript:history.go(-1);" id="" value="返回" class="newsub2">
    </div>

</div>

<script>
    var image = '';

    function selectImage(file) {
        if (!file.files || !file.files[0]) {
            return;
        }
        var reader = new FileReader();
        reader.onload = function(evt) {
            document.getElementById('image').src = evt.target.result;
            image = evt.target.result;
        }
        reader.readAsDataURL(file.files[0]);
    }

    function uploadImage() {
        $.ajax({
            type: 'POST',
            url: 'ajax/uploadimage',
            data: {
                image: image
            },
            async: false,
            dataType: 'json',
            success: function(data) {
                if (data.success) {
                    alert('上传成功');
                } else {
                    alert('上传失败');
                }
            },
            error: function(err) {
                alert('网络故障');
            }
        });
    }
</script>
<script src="http://libs.baidu.com/jquery/1.11.3/jquery.min.js"></script>

</body>
</html>